#include "memoryPool.h"

const static int round = 10;
const static int times = 100000;

class people
{
    int id;
    std::string name;
};

int main()
{
    memory_pool<people> pool;
    std::vector<people*> v(times);
    int start = clock();
    for(int i = 0; i < round; i++)
    {
        for(int j = 0; j < times; j++)
        {
            v[j] = pool.New();
        }   
        for(int j = 0; j < times; j++)
        {
            pool.Delete(v[j]);
        }
    }
    int end = clock();
    cout << "使用内存池进行内存申请一共使用：" << end - start << endl;
    start = clock();
    for(int i = 0; i < round; i++)
    {
        for(int j = 0; j < times; j++)
        {
            v[j] = new people;
        }   
        for(int j = 0; j < times; j++)
        {
            delete(v[j]);
        }
    }
    end = clock();
    cout << "使用系统进行内存申请一共使用：" << end - start << endl;
    return 0;
}